package 二分快速幂.整数拆分;

/**
 * TODO
 *
 * @className: zscf
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-05-10 11:45
 **/
public class zscf {

    public static void main(String[] args) {
        System.out.println(integerBreak(2));
        System.out.println(integerBreak(10));
    }
    public static int integerBreak(int n) {
        int k = n / 3;
        if ( n <= 3 ){
            return n-1;
        }
        if ( n == 3*k && k>=2){
            return (int) Math.pow(3,k);
        }
        if ( n == 3*k+1 && k>=1 ){
            return (int) Math.pow(3,k-1)*4;
        }
        if ( n == 3*k+2 && k>=1 ){
            return (int) Math.pow(3,k)*2;
        }
        return -1;
    }
}
